package org.linlinjava.litemall.db.service;

import com.github.yulichang.base.MPJBaseServiceImpl;
import org.linlinjava.litemall.db.dao.LumierePayMemberUserLogMapper;
import org.linlinjava.litemall.db.domain.LumierePayMemberUserExample;
import org.linlinjava.litemall.db.domain.LumierePayMemberUserLog;
import org.linlinjava.litemall.db.domain.LumierePayMemberUserLogExample;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

@Service
public class LumierePayMemberUserLogService extends MPJBaseServiceImpl<LumierePayMemberUserLogMapper,LumierePayMemberUserLog> {

    @Resource
    private LumierePayMemberUserLogMapper lumierePayMemberUserLogMapper;

    public List<LumierePayMemberUserLog> list(LumierePayMemberUserLogExample example){
        return lumierePayMemberUserLogMapper.selectByExample(example);
    }

    public void add(LumierePayMemberUserLog LumierePayMemberUserLog){
        lumierePayMemberUserLogMapper.insert(LumierePayMemberUserLog);
    }

    public void update(LumierePayMemberUserLog LumierePayMemberUserLog){
        lumierePayMemberUserLogMapper.updateByPrimaryKeySelective(LumierePayMemberUserLog);
    }

    public void delete(Integer payMemberUserLogId){
        lumierePayMemberUserLogMapper.logicalDeleteByPrimaryKey(payMemberUserLogId);
    }

    public Integer countByMemberId(LumierePayMemberUserLogExample example){
        return (int)lumierePayMemberUserLogMapper.countByExample(example);
    }

    public Integer countMemberUserByMemberId(Integer userId,Integer memberId){
        LumierePayMemberUserLogExample example = new LumierePayMemberUserLogExample();
        example.or().andDeletedEqualTo(false).andPurchaseIdEqualTo(userId).andPayMemberIdEqualTo(memberId);

        return (int) lumierePayMemberUserLogMapper.countByExample(example);
    }


}
